package com.xcjw.com.View;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ImageView;

import com.xcjw.com.R;


/**
 * @packname com.awl.com.view
 * @filename MyDialog
 * @date on 2018/7/17 10:34
 *****/
public class MyDialog extends Dialog implements View.OnClickListener {
private ImageView imageview,imageview2;
      public MyDialog(Context context, ImageView imageView) {
            super(context, R.style.myDialog);
            //初始化布局
            setContentView(R.layout.layout_select_photo);
            Window dialogWindow = getWindow();
            dialogWindow.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
            dialogWindow.setGravity(Gravity.CENTER_HORIZONTAL);

            setCanceledOnTouchOutside(true);
            imageview = imageView;

            findViewById(R.id.btn_camera).setOnClickListener(this);
            findViewById(R.id.btn_gallery).setOnClickListener(this);
            findViewById(R.id.btn_cancel).setOnClickListener(this);
      }

      @Override
      public void onClick(View v) {
            // TODO Auto-generated method stub
            switch (v.getId()) {
                  case R.id.btn_camera:
                        onButtonClickListener.camera(imageview);
                        break;
                  case R.id.btn_gallery:
                        onButtonClickListener.gallery(imageview);
                        break;
                  case R.id.btn_cancel:
                        onButtonClickListener.cancel(imageview);
                        break;

                  default:
                        break;
            }
      }
      /**
       * 按钮的监听器
       * @author Orathee
       * @date 2014年3月20日 下午4:28:39
       */
      public interface OnButtonClickListener{
            void camera(ImageView imageView);
            void gallery(ImageView imageView);
            void cancel(ImageView imageView);
      }
      private OnButtonClickListener onButtonClickListener;

      public OnButtonClickListener getOnButtonClickListener() {
            return onButtonClickListener;
      }

      public void setOnButtonClickListener(OnButtonClickListener onButtonClickListener,ImageView imageView) {
            this.onButtonClickListener = onButtonClickListener;
            imageView = this.imageview;
      }

}